package com.yxp.offer;

import java.util.*;

/**
 * @author : yang.xp
 * @date : 2021/8/30 10:04
 * @description : 剑指 Offer 40. 最小的k个数
 */
public class Problem40 {

    public static void main(String[] args) {
        Problem40 problem40 = new Problem40();
        System.out.println(problem40.getLeastNumbers(new int[]{3, 30, 34, 5, 9}, 3));
    }

    public int[] getLeastNumbers(int[] arr, int k) {
        Arrays.sort(arr);
        int[] resultArr = new int[k];
        for (int i = 0; i < k; i++) {
            resultArr[i] = arr[i];
        }
        return resultArr;
    }
}
